% plot the g/f curve for an adaptive exponential neuron.
% Pyramid cell rate is -4.45 + 8.7spikes/nS.
% FS cell rate is -16.2 + 15.1 spikes/nS.
% This is a script-- no parameters.



b=[];
d=[];
g_vals = 0:.25:30;
a=zeros(size(g_vals));
first_spike_rate=zeros(size(g_vals));
for neuron = 1:2

    k=1;for i =g_vals,[a(k) junk first_spike_rate(k)]=adaptexp(i,0,neuron,true);k=k+1;end,close all,
    b=[b a'];
    d=[d first_spike_rate'];
end

c=[];
e=[];
i_vals = -0:-10:-1000;
a=zeros(size(i_vals));
first_spike_rate=zeros(size(i_vals));
for neuron = 1:2

    k=1;for i = i_vals,[a(k) junk first_spike_rate(k)]=adaptexp(i,0,neuron,false);k=k+1;end,close all,
    c=[c a'];
    e=[e first_spike_rate'];
end

disp('linear fit for g/f curve:');
polyfit(g_vals',b(:,1),1)

disp('linear fit for I/f curve:');
polyfit(i_vals',c(:,1),1)

figure (1);
subplot(2,1,1);
plot(g_vals,b,'-')
xlabel('g (nS)','FontSize',12);
ylabel ('Firing rate (Hz)','FontSize',12);
title ('Conductance/firing rate curve for neuron','FontSize',14);
legend('Adaptive exponential pyramidal cell','FS cell')

subplot(2,1,2);
plot(i_vals,c,'-')
xlabel('I (pA)','FontSize',12);
ylabel ('Firing rate (Hz)','FontSize',12);
title ('Current/firing rate curve for neuron','FontSize',14);
legend('Adaptive exponential pyramidal cell','FS cell')


figure (2);
subplot(2,1,1);
plot(g_vals,d,'-')
xlabel('g (nS)','FontSize',12);
ylabel ('Initial firing rate (Hz)','FontSize',12);
title ('Conductance/firing rate curve for neuron','FontSize',14);
legend('Adaptive exponential pyramidal cell','FS cell')

subplot(2,1,2);
plot(i_vals,e,'-')
xlabel('I (pA)','FontSize',12);
ylabel ('Initial firing rate (Hz)','FontSize',12);
title ('Current/firing rate curve for neuron','FontSize',14);
legend('Adaptive exponential pyramidal cell','FS cell')

